<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Cheetah Software: LegController.h File Reference</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Cheetah Software
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="../../index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="../../namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="../../annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="../../files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="../../search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="../../search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="../../files.html"><span>File&#160;List</span></a></li>
      <li><a href="../../globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('d0/d41/_leg_controller_8h.html','../../');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">LegController.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Common Leg Control Interface and Leg Control Algorithms.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;eigen3/Eigen/Dense&gt;</code><br />
<code>#include &quot;leg_control_command_lcmt.hpp&quot;</code><br />
<code>#include &quot;leg_control_data_lcmt.hpp&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d3/dc7/_quadruped_8h_source.html">Dynamics/Quadruped.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d0/d6a/_spine_board_8h_source.html">SimUtilities/SpineBoard.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d9/d42/ti__boardcontrol_8h_source.html">SimUtilities/ti_boardcontrol.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="../../d9/d8e/cpp_types_8h_source.html">cppTypes.h</a>&quot;</code><br />
</div><div class="textblock"><div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="../../closed.png" alt="+"/> Include dependency graph for LegController.h:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../dd/dd3/_leg_controller_8h__incl.png" border="0" usemap="#_leg_controller_8h" alt=""/></div>
<map name="_leg_controller_8h" id="_leg_controller_8h">
</map>
</div>
</div><div class="textblock"><div id="dynsection-1" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-1-trigger" src="../../closed.png" alt="+"/> This graph shows which files directly or indirectly include this file:</div>
<div id="dynsection-1-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-1-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d1/ddf/_leg_controller_8h__dep__incl.png" border="0" usemap="#_leg_controller_8hdep" alt=""/></div>
<map name="_leg_controller_8hdep" id="_leg_controller_8hdep">
</map>
</div>
</div>
<p><a href="../../d0/d41/_leg_controller_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d1/d6a/struct_leg_controller_command.html">LegControllerCommand&lt; T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d7/d6e/struct_leg_controller_data.html">LegControllerData&lt; T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d0/d96/class_leg_controller.html">LegController&lt; T &gt;</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ab89026e04e11b835c2c981ff9048e1c3"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ab89026e04e11b835c2c981ff9048e1c3"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="../../d0/d41/_leg_controller_8h.html#ab89026e04e11b835c2c981ff9048e1c3">computeLegJacobianAndPosition</a> (<a class="el" href="../../dc/d66/class_quadruped.html">Quadruped</a>&lt; T &gt; &amp;quad, <a class="el" href="../../d9/d8e/cpp_types_8h.html#a6f07728c866b15ff0676a9b2ebfd2ba6">Vec3</a>&lt; T &gt; &amp;q, <a class="el" href="../../d9/d8e/cpp_types_8h.html#aa8cb424e643d476ea485238dad7c3e18">Mat3</a>&lt; T &gt; *J, <a class="el" href="../../d9/d8e/cpp_types_8h.html#a6f07728c866b15ff0676a9b2ebfd2ba6">Vec3</a>&lt; T &gt; *p, int leg)</td></tr>
<tr class="separator:ab89026e04e11b835c2c981ff9048e1c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Common Leg Control Interface and Leg Control Algorithms. </p>
<p>Implements low-level leg control for Mini Cheetah and Cheetah 3 Robots Abstracts away the difference between the SPIne and the TI Boards All quantities are in the "leg frame" which has the same orientation as the body frame, but is shifted so that 0,0,0 is at the ab/ad pivot (the "hip
frame"). </p>

<p>Definition in file <a class="el" href="../../d0/d41/_leg_controller_8h_source.html">LegController.h</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ab89026e04e11b835c2c981ff9048e1c3"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void computeLegJacobianAndPosition </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d66/class_quadruped.html">Quadruped</a>&lt; T &gt; &amp;&#160;</td>
          <td class="paramname"><em>quad</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../d9/d8e/cpp_types_8h.html#a6f07728c866b15ff0676a9b2ebfd2ba6">Vec3</a>&lt; T &gt; &amp;&#160;</td>
          <td class="paramname"><em>q</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../d9/d8e/cpp_types_8h.html#aa8cb424e643d476ea485238dad7c3e18">Mat3</a>&lt; T &gt; *&#160;</td>
          <td class="paramname"><em>J</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../d9/d8e/cpp_types_8h.html#a6f07728c866b15ff0676a9b2ebfd2ba6">Vec3</a>&lt; T &gt; *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>leg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Compute the position of the foot and its Jacobian. This is done in the local leg coordinate system. If J/p are NULL, the calculation will be skipped. </p>

<p>Definition at line <a class="el" href="../../da/d2d/_leg_controller_8cpp_source.html#l00240">240</a> of file <a class="el" href="../../da/d2d/_leg_controller_8cpp_source.html">LegController.cpp</a>.</p>

<p>References <a class="el" href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped&lt; T &gt;::_abadLinkLength</a>, <a class="el" href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped&lt; T &gt;::_hipLinkLength</a>, <a class="el" href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped&lt; T &gt;::_kneeLinkLength</a>, <a class="el" href="../../da/d2d/_leg_controller_8cpp.html#a3a7be9c3e33a9279b590659caa8a9f79">computeLegJacobianAndPosition&lt; double &gt;()</a>, <a class="el" href="../../da/d2d/_leg_controller_8cpp.html#a8c6ba0d01a88c7e4168cc3952b1c1c45">computeLegJacobianAndPosition&lt; float &gt;()</a>, and <a class="el" href="../../d3/dc7/_quadruped_8h_source.html#l00074">Quadruped&lt; T &gt;::getSideSign()</a>.</p>
<div class="fragment"><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;                                                        {</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;  T l1 = quad.<a class="code" href="../../dc/d66/class_quadruped.html#add43dcb4994e6e31375c4515e8de397d">_abadLinkLength</a>;</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;  T l2 = quad.<a class="code" href="../../dc/d66/class_quadruped.html#a2b1208249b4fa5e9dc3b08916fae04c7">_hipLinkLength</a>;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;  T l3 = quad.<a class="code" href="../../dc/d66/class_quadruped.html#ae752ca0d75b7e1ae759c1285be62d068">_kneeLinkLength</a>;</div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;  T sideSign = quad.<a class="code" href="../../dc/d66/class_quadruped.html#a6e180d3c6ca3c3b5bb3121324441e2c4">getSideSign</a>(leg);</div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;  T s1 = std::sin(q(0));</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;  T s2 = std::sin(q(1));</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;  T s3 = std::sin(q(2));</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;  T c1 = std::cos(q(0));</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;  T c2 = std::cos(q(1));</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;  T c3 = std::cos(q(2));</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;  T c23 = c2 * c3 - s2 * s3;</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;  T s23 = s2 * c3 + c2 * s3;</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;</div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;  <span class="keywordflow">if</span> (J) {</div><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    J-&gt;operator()(0, 0) = 0;</div><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    J-&gt;operator()(0, 1) = l3 * c23 + l2 * c2;</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    J-&gt;operator()(0, 2) = l3 * c23;</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;    J-&gt;operator()(1, 0) = l3 * c1 * c23 + l2 * c1 * c2 - l1 * sideSign * s1;</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;    J-&gt;operator()(1, 1) = -l3 * s1 * s23 - l2 * s1 * s2;</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;    J-&gt;operator()(1, 2) = -l3 * s1 * s23;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    J-&gt;operator()(2, 0) = l3 * s1 * c23 + l2 * c2 * s1 + l1 * sideSign * c1;</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;    J-&gt;operator()(2, 1) = l3 * c1 * s23 + l2 * c1 * s2;</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    J-&gt;operator()(2, 2) = l3 * c1 * s23;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;  }</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;  <span class="keywordflow">if</span> (p) {</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;    p-&gt;operator()(0) = l3 * s23 + l2 * s2;</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;    p-&gt;operator()(1) = l1 * sideSign * c1 + l3 * (s1 * c23) + l2 * c2 * s1;</div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;    p-&gt;operator()(2) = l1 * sideSign * s1 - l3 * (c1 * c23) - l2 * c1 * c2;</div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;  }</div><div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;}</div><div class="ttc" id="class_quadruped_html_a2b1208249b4fa5e9dc3b08916fae04c7"><div class="ttname"><a href="../../dc/d66/class_quadruped.html#a2b1208249b4fa5e9dc3b08916fae04c7">Quadruped::_hipLinkLength</a></div><div class="ttdeci">T _hipLinkLength</div><div class="ttdef"><b>Definition:</b> <a href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped.h:62</a></div></div>
<div class="ttc" id="class_quadruped_html_ae752ca0d75b7e1ae759c1285be62d068"><div class="ttname"><a href="../../dc/d66/class_quadruped.html#ae752ca0d75b7e1ae759c1285be62d068">Quadruped::_kneeLinkLength</a></div><div class="ttdeci">T _kneeLinkLength</div><div class="ttdef"><b>Definition:</b> <a href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped.h:62</a></div></div>
<div class="ttc" id="class_quadruped_html_a6e180d3c6ca3c3b5bb3121324441e2c4"><div class="ttname"><a href="../../dc/d66/class_quadruped.html#a6e180d3c6ca3c3b5bb3121324441e2c4">Quadruped::getSideSign</a></div><div class="ttdeci">static T getSideSign(int leg)</div><div class="ttdef"><b>Definition:</b> <a href="../../d3/dc7/_quadruped_8h_source.html#l00074">Quadruped.h:74</a></div></div>
<div class="ttc" id="class_quadruped_html_add43dcb4994e6e31375c4515e8de397d"><div class="ttname"><a href="../../dc/d66/class_quadruped.html#add43dcb4994e6e31375c4515e8de397d">Quadruped::_abadLinkLength</a></div><div class="ttdeci">T _abadLinkLength</div><div class="ttdef"><b>Definition:</b> <a href="../../d3/dc7/_quadruped_8h_source.html#l00062">Quadruped.h:62</a></div></div>
</div><!-- fragment -->
<p><div id="dynsection-2" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-2-trigger" src="../../closed.png" alt="+"/> Here is the call graph for this function:</div>
<div id="dynsection-2-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-2-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_cgraph.png" border="0" usemap="#d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_cgraph" alt=""/></div>
<map name="d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_cgraph" id="d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_cgraph">
</map>
</div>
</p>

<p><div id="dynsection-3" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-3-trigger" src="../../closed.png" alt="+"/> Here is the caller graph for this function:</div>
<div id="dynsection-3-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-3-content" class="dyncontent" style="display:none;">
<div class="center"><img src="../../d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_icgraph.png" border="0" usemap="#d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_icgraph" alt=""/></div>
<map name="d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_icgraph" id="d0/d41/_leg_controller_8h_ab89026e04e11b835c2c981ff9048e1c3_icgraph">
</map>
</div>
</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="../../dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="../../dir_61bfb0b3cdda81b1b0355ba34eb3b1eb.html">dhkim</a></li><li class="navelem"><a class="el" href="../../dir_adee5b101e079090017bb4e91c628ead.html">Public_Repository</a></li><li class="navelem"><a class="el" href="../../dir_7fc07a7b97001e7b1d18e11da761e2de.html">Cheetah-Software</a></li><li class="navelem"><a class="el" href="../../dir_860379c26524a894b3cf97b5b1ba5bdb.html">common</a></li><li class="navelem"><a class="el" href="../../dir_275ce76ae8a9e2090fbb7142d3994a0e.html">include</a></li><li class="navelem"><a class="el" href="../../dir_2bdcd228c7292c6576e24d4a4e6e91f5.html">Controllers</a></li><li class="navelem"><a class="el" href="../../d0/d41/_leg_controller_8h.html">LegController.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="../../doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
